﻿using System.Collections.Generic;
using System.Linq;

namespace Pogo.Data
{
   internal class Device : PogoObject, IDevice
   {
      internal string DeviceID { get; set; }
      internal string Type { get; set; }
      internal int Flags { get; set; }
      internal SKU SKU { get; set; }
      internal int ProvisionFlags { get; set; }
      internal License Plan { get; set; }
      internal List<Service> Services { get; set; }
      internal string OwnerID { get; set; }

      protected IEnumerable<string> features = null;

      #region IDevice Members

      public string Name { get; set; }
      public string Version { get; set; }
      public string SerialNum { get; set; }
      public bool Authorized { get; set; }

      public IEnumerable<IFileService> FileServices
      {
         get { return Services.Where(s => s.HasFiles); }
      }

      public IEnumerable<string> Features
      {
         get { return features ?? (features = Root.CloudService.ListFeatures(AuthToken, DeviceID)); }
      }

      #endregion
   }

   public enum SortType
   {
      None,
      Name,
      Date,
      Type,
      Size
   }

   public enum SortDirection
   {
      Ascending,
      Descending
   }

   public class SKU
   {
      public int ID { get; set; }
      public string OEM { get; set; }
      public string Name { get; set; }
      public string UserName { get; set; }
      public int Terms { get; set; }
   }

   public class License
   {
      public int Duration { get; set; }
      public bool Limited { get; set; }
      public string Name { get; set; }
      public long StartDate { get; set; }
      public string Type { get; set; }
   }
}